<?php
/*
Template Name: Movies
*/
?>
<?php get_header();?>
<?php get_sidebar();?>
    <div id="homeWrapper" class="clearfix">
<?php 
//		//////////////////////////
$args = array(
    'orderby' => 'id',
	'order' => 'DESC',
    'hide_empty' => 0,
    'taxonomy' => 'the-loai-phim',
	'post_type' => 'danh-sach-phim',
	'parent' => 0
);
$categories = get_categories($args);  //print_r($categories);die;

foreach( $categories as $category ) {
	$newargs = array( 'post_type'=>'danh-sach-phim',
						'tax_query'=>array(
											array(
												'taxonomy'=>'the-loai-phim',
												'field'=>'slug',
												'terms'=>$category->slug
												)
											)
						);
	?>
    <div class="box-fim" style="float:left; width:600px;">
     <h2 style="margin-bottom:20px; "><a style="color:#ffffff; background-color:#0077B0; padding:8px 20px; margin:10px 0px; float:left; width:600px" href="<?php echo get_term_link($category,$category->taxonomy);?>" class="tit-link"><?php echo $category->name;?></a></h2>
    <?php
	query_posts($newargs); 
	if(have_posts()) : while(have_posts()) : the_post();	?>
	
		<div <?php post_class($p3);?> id="product-<?php the_ID();?>" style="float:left; padding:10px; margin-bottom:10px; text-align:center"> 
          <?php the_post_thumbnail(array('class'=>'image-1'));  ?>
                <a href="<?php the_permalink();?>"><h3 class="product-title"><?php the_title();?></h3></a>
                <div class="info">
                        <p style="margin-top:5px; color:#ffffff"><?php echo get_post_meta($post->ID,'wpcf-phone',true);?></p>
                        <p class="product-status">
                            <?php 
                            $product_status = get_post_meta($post->ID,'wpcf-product-status',true);
							if($product_status == '1')
                            	echo '<strong style="color:green;">Đang chiếu</strong>';
							else
								echo '<strong style="color:green;">Sắp chiếu</strong>';
                            ?>
                        </p>
                        <p class="product-status"><?php echo get_post_meta($post->ID,'actions',true);?></p>
                        <a class="order-button" href="<?php the_permalink();?>">Xem chi tiết</a>
                        </div> 
       </div>
	<?php	
	endwhile;		//die;					
	endif;
	echo'</div>';
}
//////////////////////////////////
?>

    </div><!--end #homeWrapper-->
 
 <!--Add dropdown menu categories--->   
<?php
 /* $cates = get_categories('taxonomy=the-loai-phim&parent=0'); //print_r($cates);die;
  $select = "<select name='cat' id='cat' class='postform'>n";
  $select.= "<option value='-1'>Select category</option>n";
  
  foreach($cates as $cate){
	  $parent = $cate->term_id;
    if($cate->count > 0){
        $select.= "<option value='".$cate->slug."'>".$cate->name."</option>";
		$subcates = get_categories(array('taxonomy'=>'the-loai-phim',
										'hide_empty'=>0,
										'parent'=>$parent
										)
									);
		if(count($subcates)>0){
			foreach($subcates as $subcate){
				$select .= "<option value='".$subcate->slug."'>--".$subcate->name."</option>";	
			}
		}
    }
  }
  
  $select.= "</select>";
  
  echo $select;*/
?>
  
<script type="text/javascript">
  /*  var dropdown = document.getElementById("cat");
    function onCatChange() {
        if ( dropdown.options[dropdown.selectedIndex].value != -1 ) {
            location.href = "<?php// echo home_url();?>/the-loai-phim/"+dropdown.options[dropdown.selectedIndex].value+"/";
        }
    }
    dropdown.onchange = onCatChange;*/
</script>
<!--End add dropdown menu categories---->
<?php get_footer(); ?>